package cn.truistic.enmicromsg.base;

import android.content.Context;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import cn.truistic.enmicromsg.app.EnApplication;
import cn.truistic.enmicromsg.common.util.ConfirmDialog;
import cn.truistic.enmicromsg.common.util.WxHeple;

/**
 * BaseActivity
 * 执行步骤：
 * 1. 结束微信进程： execShellCmd ()
 */
public abstract class BaseActivity extends AppCompatActivity {

    private ConfirmDialog confirmDialog; //判断开启服务判断
    protected Context mContext ;
    protected EnApplication mEnApplication;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mContext = getApplicationContext();
        mEnApplication = (EnApplication) getApplication();
        confirmDialog = new ConfirmDialog(this);
    }

    //判断服务是否开启, 如未开启去设置页面进行手动开启
    public boolean isAccessibilitySettingsOn() {
        Log.e("TAG" ,WxHeple.isAccessibilitySettingsOn(mContext)+"-------->");
        if (WxHeple.isAccessibilitySettingsOn(mContext)) {
            //开启
            return true;
        } else {
            //未开启
            confirmDialog.show();
            return false;
        }
    }

    //睡眠时间 ，如果操作过快微信可能会封号！
    public void sleepMiss(long miss ){
        try {
            Thread.sleep( miss ) ;
        } catch (InterruptedException e ) {
            e.printStackTrace();
        }
    }
}
